/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tv.pool.modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import tv.inventario.modelo.Producto;

/**
 *
 * @author ctrosch
 */
@Entity
@Table(name = "USR_POOLIP")
@IdClass(ItemProductoPoolPK.class)
public class ItemProductoPool implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "USR_POOLIP_NRPOOL", nullable = false)
    private int nroPool;
    @Id
    @Column(name = "USR_POOLIP_NORDEN", nullable = false)
    private int orden;

    //Pool
    @ManyToOne
    @JoinColumn(name = "USR_POOLIP_NRPOOL", referencedColumnName = "USR_POOL_NRPOOL", nullable = false, insertable=false, updatable=false)
    private Pool pool;
    
    @JoinColumns({
    @JoinColumn(name = "USR_POOLIP_TIPPRO", referencedColumnName = "STMPDH_TIPPRO", nullable = false),
    @JoinColumn(name = "USR_POOLIP_ARTCOD", referencedColumnName = "STMPDH_ARTCOD", nullable = false)
    })
    @ManyToOne
    private Producto producto;


    @Column(name = "USR_POOLIP_PCINOR", precision = 20, scale = 6)
    private BigDecimal precioNormal;
    @Column(name = "USR_POOLIP_PRCPOL", precision = 20, scale = 6)
    private BigDecimal precioPublicado;

    @Column(name = "USR_POOLIP_CNTMIN", precision = 2, scale = 4)
    private BigDecimal cantidadMinima;
    @Column(name = "USR_POOLIP_CNTMAX", precision = 2, scale = 4)
    private BigDecimal cantidadMaxima;

    @Column(name = "USR_PO_FECALT")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecalt;
    @Column(name = "USR_PO_FECMOD")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecmod;
    @Column(name = "USR_PO_USERID", length = 15)
    private String userid;
    @Column(name = "USR_PO_ULTOPR")
    private Character ultopr;
    @Column(name = "USR_PO_DEBAJA")
    private Character debaja;
    
    @Column(name = "USR_PO_OALIAS", length = 10)
    private String oalias;

    @Transient boolean persistido;
        
    public ItemProductoPool() {

        this.debaja = 'N';
        this.oalias = "USR_POOLIP";
        this.fecalt = new Date();
        this.fecmod = new Date();
        this.ultopr = 'A';
        this.userid = "TIVI";
        this.persistido = false;
    }

    public ItemProductoPool(int nroPool, int orden) {
        this.nroPool = nroPool;
        this.orden = orden;
        
        this.debaja = 'N';
        this.oalias = "USR_POOLIP";
        this.fecalt = new Date();
        this.fecmod = new Date();
        this.ultopr = 'A';
        this.userid = "TIVI";

        this.persistido = false;
    }



    public BigDecimal getCantidadMaxima() {
        return cantidadMaxima;
    }

    public void setCantidadMaxima(BigDecimal cantidadMaxima) {
        this.cantidadMaxima = cantidadMaxima;
    }

    public BigDecimal getCantidadMinima() {
        return cantidadMinima;
    }

    public void setCantidadMinima(BigDecimal cantidadMinima) {
        this.cantidadMinima = cantidadMinima;
    }

    public Character getDebaja() {
        return debaja;
    }

    public void setDebaja(Character debaja) {
        this.debaja = debaja;
    }

    public Date getFecalt() {
        return fecalt;
    }

    public void setFecalt(Date fecalt) {
        this.fecalt = fecalt;
    }

    public Date getFecmod() {
        return fecmod;
    }

    public void setFecmod(Date fecmod) {
        this.fecmod = fecmod;
    }

    public int getNroPool() {
        return nroPool;
    }

    public void setNroPool(int nroPool) {
        this.nroPool = nroPool;
    }

    public String getOalias() {
        return oalias;
    }

    public void setOalias(String oalias) {
        this.oalias = oalias;
    }

    public int getOrden() {
        return orden;
    }

    public void setOrden(int orden) {
        this.orden = orden;
    }

    public BigDecimal getPrecioNormal() {
        return precioNormal;
    }

    public void setPrecioNormal(BigDecimal precioNormal) {
        this.precioNormal = precioNormal;
    }

    public BigDecimal getPrecioPublicado() {
        return precioPublicado;
    }

    public void setPrecioPublicado(BigDecimal precioPublicado) {
        this.precioPublicado = precioPublicado;
    }

    public Producto getProducto() {
        return producto;
    }

    public void setProducto(Producto producto) {
        this.producto = producto;
    }

    public Character getUltopr() {
        return ultopr;
    }

    public void setUltopr(Character ultopr) {
        this.ultopr = ultopr;
    }

    public String getUserid() {
        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public boolean isPersistido() {
        return persistido;
    }

    public void setPersistido(boolean persistido) {
        this.persistido = persistido;
    }

    public Pool getPool() {
        return pool;
    }

    public void setPool(Pool pool) {
        this.pool = pool;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ItemProductoPool other = (ItemProductoPool) obj;
        if (this.nroPool != other.nroPool) {
            return false;
        }
        if (this.orden != other.orden) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 83 * hash + this.nroPool;
        hash = 83 * hash + this.orden;
        return hash;
    }

    @Override
    public String toString() {
        return "ItemProductoPool{" + "nroPool=" + nroPool + "orden=" + orden + '}';
    }
    
}
